from collections import defaultdict as dd
from collections import deque
import bisect
import heapq
def ri():
return int(input())
def rl():
return list(map(int, input().split()))
def solve():
n, x = rl()
A = rl()
copies = dd(int)
for a in A:
if a >= x: continue
copies[a] += 1
curr = x - 1
need = 0
factor = x
while curr >= 1:
if need == 0 and copies[curr] != 0:
need = factor
if need > n:
print ("No")
return
if need != 0:
if need >= copies[curr]:
need -= copies[curr]
else:
need = (need-copies[curr]) % factor
need *= curr
if factor <= n * 1000000:
factor *= curr
curr -= 1
if need == 0:
print ("Yes")
else:
print ("No")
mode = 's'
if mode == 'T':
t = ri()
for i in range(t):
solve()
else:
solve()
#include<bits/stdc++.h>
using namespace std;
int a[1000009];
int main () {
int n, m, ans = 1;
cin >> n >> m;
int b[n];
for (int i = 0; i < n; i++) {
cin >> b[i];
a[b[i]]++;
if (b[i] < m) ans = 0;
}
if (ans) cout << "Yes";
else {
ans = 1;
for (int i = 1; i < m; i++) {
if ((a[i]%(i+1)) == 0) {
a[i+1] += (a[i]/(i+1));
continue;
}
else {
ans = 0;
break;
}
}
if (ans) cout << "Yes";
else cout << "No";
}
}
Numbers in a matrix | Sequences |
Split houses | Divisible |
Three primes | Coprimes |
Cost of balloons | One String No Trouble |
Help Jarvis! | Lift queries |
Goki and his breakup | Ali and Helping innocent people |
Book of Potion making | Duration |
Birthday Party | e-maze-in |
Bricks Game | Char Sum |
Two Strings | Anagrams |
Prime Number | Lexical Sorting Reloaded |
1514A - Perfectly Imperfect Array | 580A- Kefa and First Steps |
1472B- Fair Division | 996A - Hit the Lottery |
MSNSADM1 Football | MATCHES Playing with Matches |
HRDSEQ Hard Sequence | DRCHEF Doctor Chef |